package com.soilflow.web.controller.know;

import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.domain.AjaxResult;
import com.soilflow.common.core.page.TableDataInfo;
import com.soilflow.common.domain.dto.KnowsReportReplyDto;
import com.soilflow.common.domain.vo.KnowsReportReplyVo;
import com.soilflow.know.service.KnowsReportReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/report/reply")
@RestController
public class KnowsReportReplyController extends BaseController {

    @Autowired
    private KnowsReportReplyService knowsReportReplyService;


    /**
     * 百事通举报回复列表
     * @param dto
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo reportReplyList(KnowsReportReplyDto dto){
        startPage();
        List<KnowsReportReplyVo> list =  knowsReportReplyService.reportReplyList(dto);
        return getDataTable(list);
    }


    /**
     * 添加百事通举报回复信息
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public AjaxResult addReportReply(@RequestBody KnowsReportReplyDto dto){
        knowsReportReplyService.addReportReply(dto);
        return AjaxResult.success();
    }


    /**
     * 更新百事通举报回复信息
     * @param dto
     * @return
     */
    @PutMapping("/update")
    public AjaxResult updateReportReply(@RequestBody KnowsReportReplyDto dto){
        knowsReportReplyService.updateReportReply(dto);
        return AjaxResult.success();
    }


    /**
     * 获取百事通举报信息回复详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public AjaxResult getReportReplyById(@PathVariable Long id){
        KnowsReportReplyVo vo = knowsReportReplyService.getReportReplyById(id);
        return AjaxResult.success(vo);
    }


    /**
     * 删除百事通举报回复信息
     * @param ids
     * @return
     */
    @DeleteMapping("/del/{ids}")
    public AjaxResult delReportReply(@PathVariable List<Long> ids){
        knowsReportReplyService.removeByIds(ids);
        return AjaxResult.success();
    }
}
